﻿/*
*  ChgDoc CMS - GNU General Public License, version 3 (GPL-3.0)
*  Copyright (C)  2012. Ian Quigley
*  
*  This program is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, either version 3 of the License, or
*  (at your option) any later version.
*  
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*/


editTextDialog = function (options) {

    var internalOptions = {
        title: 'Edit text',
        text: '',
        ok: function (text) { }
    };

    for (var member in options)
        internalOptions[member] = options[member];

    this.show = function () {

        $('#editTextDialog').remove();
        $('body').append("<div id='editTextDialog'><textarea style='font-family: lucida console, monospaced; width: 100%; height:100%; margin-bottom: -220px; margin-right: -70px;'>" + internalOptions.text + "</textarea></div>");
        setCatchTab($('div#editTextDialog textarea'));

        $('#editTextDialog').dialog({
            title: this.title,
            width: 600,
            height: 400,
            position: 'center',
            buttons: {
                "Ok": function () { internalOptions.ok($('#editTextDialog textarea').val()); $(this).dialog("close"); },
                "Cancel": function () { $(this).dialog("close"); }
            }
        });
    }
};